package com.ihg.hiex.admin.dao.session;

import java.util.List;

import com.demo2do.core.persistence.annotation.Dao;
import com.demo2do.core.persistence.annotation.Query;
import com.demo2do.core.persistence.annotation.Variable;
import com.ihg.hiex.entity.session.Session;
import com.ihg.hiex.entity.session.during.SessionAnchorScore;
import com.ihg.hiex.entity.session.during.SessionCompetencyScore;
import com.ihg.hiex.entity.user.Assessor;
import com.ihg.hiex.entity.user.Delegate;

/**
 * 
 * @author dan
 *
 */
@Dao("hibernate")
public interface SessionAnchorDao {
    
    /**
     * 
     * @param sessionCompetencyScore
     * @return
     */
    @Query("FROM SessionAnchorScore WHERE disabled = false AND sessionCompetencyScore = :sessionCompetencyScore ORDER BY sessionAnchor.sorting")
    public List<SessionAnchorScore> list(@Variable("sessionCompetencyScore") SessionCompetencyScore sessionCompetencyScore);

    /**
     * 
     * @param sessionCompetencyScores
     * @return
     */
    @Query("FROM SessionAnchorScore WHERE disabled = false AND sessionCompetencyScore in(:sessionCompetencyScores)")
    public List<SessionAnchorScore> list(@Variable("sessionCompetencyScores") List<SessionCompetencyScore> sessionCompetencyScores);

    /**
     * 
     * @param session
     * @param assessors
     * @param delegate
     * @param competencyName
     * @return
     */
    @Query("FROM SessionAnchorScore WHERE disabled = false AND sessionCompetencyScore.sessionExercise IS NOT NULL AND sessionCompetencyScore.sessionExercise.session = :session AND sessionCompetencyScore.sessionExercise.assessor in (:assessors) AND sessionCompetencyScore.sessionExercise.delegate = :delegate AND sessionAnchor.competencyName = :competencyName")
    public List<SessionAnchorScore> listMeetingScore(@Variable("session") Session session, @Variable("assessors") Assessor[] assessors, @Variable("delegate") Delegate delegate, @Variable("competencyName") String competencyName);
    
    /**
     * 
     * @param session
     * @param meetingName
     * @return
     */
    @Query("FROM SessionAnchorScore WHERE disabled = false AND sessionCompetencyScore.sessionExercise IS NOT NULL AND sessionCompetencyScore.sessionExercise.session = :session AND sessionAnchor.meetingName = :meetingName")
    public List<SessionAnchorScore> listMeetingScore(@Variable("session") Session session, @Variable("meetingName") String meetingName);
    
    /**
     * 
     * @param session
     * @param meetingName
     * @return
     */
    @Query("FROM SessionAnchorScore WHERE disabled = false AND sessionCompetencyScore.sessionExercise IS NOT NULL AND sessionCompetencyScore.sessionExercise.session = :session AND sessionAnchor.sessionCompetency.meetingName = :meetingName")
    public List<SessionAnchorScore> listMeetingScores(@Variable("session") Session session, @Variable("meetingName") String meetingName);
    
    /**
     * 
     * @param session
     * @param delegate
     * @param competencyName
     * @return
     */
    @Query("FROM SessionAnchorScore WHERE disabled = false AND sessionCompetencyScore.sessionExercise IS NOT NULL AND sessionCompetencyScore.sessionExercise.session = :session AND sessionCompetencyScore.sessionExercise.delegate = :delegate AND sessionAnchor.competencyName = :competencyName")
    public List<SessionAnchorScore> listMeetingScore(@Variable("session") Session session, @Variable("delegate") Delegate delegate, @Variable("competencyName") String competencyName);
    
    /**
     * 
     * @param session
     * @param assessors
     * @param delegate
     * @param competencyName
     * @return
     */
    @Query("FROM SessionAnchorScore WHERE disabled = false AND sessionCompetencyScore.sessionInBasket IS NOT NULL AND sessionCompetencyScore.sessionInBasket.session = :session AND sessionCompetencyScore.sessionInBasket.assessor in (:assessors) AND sessionCompetencyScore.sessionInBasket.delegate = :delegate AND sessionAnchor.competencyName = :competencyName")
    public List<SessionAnchorScore> listInBasketScore(@Variable("session") Session session, @Variable("assessors") Assessor[] assessors, @Variable("delegate") Delegate delegate, @Variable("competencyName") String competencyName);

    /**
     * 
     * @param session
     * @return
     */
    @Query("FROM SessionAnchorScore WHERE disabled = false AND sessionCompetencyScore.sessionInBasket IS NOT NULL AND sessionCompetencyScore.sessionInBasket.session = :session")
    public List<SessionAnchorScore> listInBasketScore(@Variable("session") Session session);

    
    /**
     * 
     * @param session
     * @param delegate
     * @param competencyName
     * @return
     */
    @Query("FROM SessionAnchorScore WHERE disabled = false AND sessionCompetencyScore.sessionInBasket IS NOT NULL AND sessionCompetencyScore.sessionInBasket.session = :session AND sessionCompetencyScore.sessionInBasket.delegate = :delegate AND sessionAnchor.competencyName = :competencyName")
    public List<SessionAnchorScore> listInBasketScore(@Variable("session") Session session, @Variable("delegate") Delegate delegate, @Variable("competencyName") String competencyName);

}
